import requests
from bs4 import BeautifulSoup
import time


generate_url = lambda i: f'http://music.163.com/discover/playlist/?order=hot&cat=%E5%85%A8%E9%83%A8&limit=35&offset={i*35}'
base_url = r'http://music.163.com'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36'
}


def parse_page(page):
    soup = BeautifulSoup(page, features='lxml')
    ul = soup.select('.m-cvrlst')[0]
    for a in ul.select('a.msk'):
        print(a['title'], base_url + a['href'])


if __name__ == '__main__':
    for i in range(5):
        url = generate_url(i)
        page = requests.get(url, headers=headers)
        parse_page(page.text)
        time.sleep(2)
